home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / a_utils / expanded.lha / test_suite / testspace.C < prev    next >
C/C++ Source or Header  |  1992-03-19  |  34KB  |  1,413 lines

  1. //
  2. // Linear-Affine-Projective Geometry Package
  3. //
  4. // testspace.C
  5. //
  6. // $Header$
  7. //
  8. // William J.R. Longabaugh 
  9. // University of Washington
  10. //
  11. // Test runs for the linear-affine-projective geometry
  12. // package described in William J.R. Longabaugh, "An Expanded
  13. // System for Coordinate-Free Geometric Programming", Master's 
  14. // thesis, University of Washington, 1992.
  15. //
  16. // Copyright (c) 1992, William J.R. Longabaugh
  17. //   Copying, use and development for non-commercial purposes permitted.
  18. //   All rights for commercial use reserved.
  19. //   This software is unsupported and without warranty; it is
  20. //   provided "as is".
  21. //
  22. // ***********************************************************************
  23.  
  24. #include "Lap.h"
  25. #include <math.h>
  26.  
  27. extern void test1(void);
  28. extern void test2(void);
  29. extern void test3(void);
  30. extern void test4(void);
  31. extern void test5(void);
  32. extern void test6(void);
  33. extern void test7(void);
  34. extern void test8(void);
  35. extern void test9(void);
  36. extern void test10(void);
  37. extern void test11(void);
  38. extern void test12(void);
  39. extern void test13(void);
  40. extern void test14(void);
  41. extern void test15(void);
  42. extern void test16(void);
  43. extern void test17(void);
  44. extern void test18(void);
  45. extern void report(AVector res);
  46. extern void truth(Boolean res, Boolean expect);
  47. extern void probe(Space root);
  48.  
  49. // ***********************************************************************
  50.  
  51. int main(void)
  52. {
  53.   test1();
  54.   test2();
  55.   test3();
  56.   test4();
  57.   test5();
  58.   test6();
  59.   test7();
  60.   test8();
  61.   test9();
  62.   test10();
  63.   test11();
  64.   test12();
  65.   test13();
  66.   test14();
  67.   test15();
  68.   test16();
  69.   test17();
  70.   test18();
  71.   return (0);
  72. }
  73.  
  74. // ***********************************************************************
  75. // Test manual stitching of spaces using arbitrary maps
  76. // ***********************************************************************
  77. // LinkLAHaveLP
  78.  
  79. void test1(void)
  80. {
  81.   cout << "ENTERING TEST1\n";
  82.   VSpace v("Test vector space", 3, TRUE);
  83.   ASpace a("Test affine space", 2, TRUE);
  84.   PSpace p("Test projective space", 2);
  85.  
  86.   VBasis bas = v.StdBasis();
  87.   Frame fra = a.StdBasis();
  88.   HFrame hfr = p.StdBasis();
  89.  
  90.   Vector v1(bas, ScalarList(2.4, 5.6, 1.2));
  91.   Vector v2(bas, ScalarList(1.0, 6.2, 8.9));
  92.   Vector v3(bas, ScalarList(7.8, 3.3, 4.6));
  93.   Vector v4(bas, ScalarList(3.4, 8.9, 0.9));
  94.   VectorEC veq1 = v1;
  95.   VectorEC veq2 = v2;
  96.   VectorEC veq3 = v3;
  97.   VectorEC veq4 = v4;
  98.   ASubSet mas("my asubset", v, GeObList(v1, v2, v3));
  99.  
  100.   APoint p1(fra, ScalarList(4.5, 9.2, 1.0));
  101.   APoint p2(fra, ScalarList(5.7, 1.3, 1.0));
  102.   APoint p3(fra, ScalarList(7.7, 8.2, 1.0));
  103.   Simplex sp("test simplex", a, GeObList(p1, p2, p3));
  104.  
  105.   PPoint pp1(hfr, ScalarList(2.4, 4.5, 7.8));
  106.   PPoint pp2(hfr, ScalarList(7.2, 3.9, 4.1));
  107.   PPoint pp3(hfr, ScalarList(5.7, 2.3, 9.1));
  108.   PPoint pp4(hfr, ScalarList(9.6, 8.4, 11.9));
  109.   PPoint pp5(hfr, ScalarList(8.1, 6.8, 16.9));
  110.   ASubSet masp("my asubset in p", p, pp1, GeObList(pp2, pp3));
  111.  
  112.   ProjectiveMap pm1(hfr, v.FullProjSet(), GeObList(veq1, veq2, veq3, veq4));
  113.   AffineMap am1(sp, mas, GeObList(v1, v2, v3));
  114.   AffineMap am2(sp, masp, GeObList(pp1, pp4, pp5));
  115.  
  116.   p.SetSpace(v, pm1);
  117.   a.SetSpace(v, am1);
  118.  
  119. // Send a point around the map loop...
  120.   
  121.   Vector vt;
  122.   VectorEC veqt;
  123.   PPoint ppt;
  124.   AVector avt;
  125.   APoint apt;
  126.   AVector avto(fra, ScalarList(2.4, 6.7, 0.0)); 
  127.   APoint orig(fra, ScalarList(4.0, 2.3, 1.0));
  128.  
  129.   vt = orig;
  130.   veqt = 2 * vt;
  131.   ppt = veqt;
  132.   apt = ppt;
  133.   report(orig - apt);
  134.  
  135.   vt = orig;
  136.   ppt = vt;
  137.   apt = ppt;
  138.   report(orig - apt);
  139.  
  140.   ppt = orig;
  141.   vt = ppt;
  142.   apt = vt;
  143.   report(orig - apt);
  144.  
  145.   vt = avto;
  146.   avt = vt;
  147.   report(avto - avt);
  148.  
  149.   probe(a);
  150. }
  151.  
  152. // ***********************************************************************
  153.  
  154. void report(AVector res)
  155. {
  156.   if (res.IsZeroVector()) { 
  157.     cout << "Success\n";
  158.   } else {
  159.     cout << "Failure\n";
  160.   }    
  161. }
  162.  
  163. // ***********************************************************************
  164. //
  165. // Probe the six-space set entries of all spaces in a six-space set
  166. //
  167.  
  168. void probe(Space root)
  169. {
  170.   char buf[200];
  171.  
  172.   for (int i = 0; i < (int)NO_RELATION; i++) {
  173.     SRelOut(cout, (SRel)i);    
  174.     cout << ":\n";
  175.     for (int j = 0; j < (int)NO_RELATION; j++) {
  176.       Space hold1 = root.GetSpace((SRel) j);
  177.       Space hold2 = hold1.GetSpace((SRel) i);
  178.       hold2.Name(buf);
  179.       cout << buf << " Dimension: " << hold2.Dim() << "\n";
  180.     }
  181.   }  
  182. }
  183.  
  184. // ***********************************************************************
  185. // LinkAPHaveLP
  186.  
  187. void test2(void)
  188. {
  189.   cout << "ENTERING TEST2\n";
  190.   VSpace v("Test vector space", 3, TRUE);
  191.   ASpace a("Test affine space", 2, TRUE);
  192.   PSpace p("Test projective space", 2);
  193.  
  194.   VBasis bas = v.StdBasis();
  195.   Frame fra = a.StdBasis();
  196.   HFrame hfr = p.StdBasis();
  197.  
  198.   Vector v1(bas, ScalarList(2.4, 5.6, 1.2));
  199.   Vector v2(bas, ScalarList(1.0, 6.2, 8.9));
  200.   Vector v3(bas, ScalarList(7.8, 3.3, 4.6));
  201.   Vector v4(bas, ScalarList(3.4, 8.9, 0.9));
  202.   VectorEC veq1 = v1;
  203.   VectorEC veq2 = v2;
  204.   VectorEC veq3 = v3;
  205.   VectorEC veq4 = v4;
  206.   ASubSet mas("my asubset", v, GeObList(v1, v2, v3));
  207.  
  208.   APoint p1(fra, ScalarList(4.5, 9.2, 1.0));
  209.   APoint p2(fra, ScalarList(5.7, 1.3, 1.0));
  210.   APoint p3(fra, ScalarList(7.7, 8.2, 1.0));
  211.   Simplex sp("test simplex", a, GeObList(p1, p2, p3));
  212.  
  213.   PPoint pp1(hfr, ScalarList(2.4, 4.5, 7.8));
  214.   PPoint pp2(hfr, ScalarList(7.2, 3.9, 4.1));
  215.   PPoint pp3(hfr, ScalarList(5.7, 2.3, 9.1));
  216.   PPoint pp4(hfr, ScalarList(9.6, 8.4, 11.9));
  217.   PPoint pp5(hfr, ScalarList(8.1, 6.8, 16.9));
  218.   ASubSet masp("my asubset in p", p, pp1, GeObList(pp2, pp3));
  219.  
  220.   ProjectiveMap pm1(hfr, v.FullProjSet(), GeObList(veq1, veq2, veq3, veq4));
  221.   AffineMap am1(sp, mas, GeObList(v1, v2, v3));
  222.   AffineMap am2(sp, masp, GeObList(pp1, pp4, pp5));
  223.  
  224.   p.SetSpace(v, pm1);
  225.   a.SetSpace(p, am2);
  226.  
  227. // Send a point around the map loop...
  228.   
  229.   Vector vt;
  230.   VectorEC veqt;
  231.   PPoint ppt;
  232.   AVector avt;
  233.   APoint apt;
  234.   AVector avto(fra, ScalarList(2.4, 6.7, 0.0)); 
  235.   APoint orig(fra, ScalarList(4.0, 2.3, 1.0));
  236.  
  237.   vt = orig;
  238.   veqt = 2 * vt;
  239.   ppt = veqt;
  240.   apt = ppt;
  241.   report(orig - apt);
  242.  
  243.   vt = orig;
  244.   ppt = vt;
  245.   apt = ppt;
  246.   report(orig - apt);
  247.  
  248.   ppt = orig;
  249.   vt = ppt;
  250.   apt = vt;
  251.   report(orig - apt);
  252.  
  253.   vt = avto;
  254.   avt = vt;
  255.   report(avto - avt);
  256.  
  257.   probe(a);
  258. }
  259.  
  260. // ***********************************************************************
  261. // LinkLAHaveAP
  262.  
  263. void test3(void)
  264. {
  265.   cout << "ENTERING TEST3\n";
  266.   VSpace v("Test vector space", 3, TRUE);
  267.   ASpace a("Test affine space", 2, TRUE);
  268.   PSpace p("Test projective space", 2);
  269.  
  270.   VBasis bas = v.StdBasis();
  271.   Frame fra = a.StdBasis();
  272.   HFrame hfr = p.StdBasis();
  273.  
  274.   Vector v1(bas, ScalarList(2.4, 5.6, 1.2));
  275.   Vector v2(bas, ScalarList(1.0, 6.2, 8.9));
  276.   Vector v3(bas, ScalarList(7.8, 3.3, 4.6));
  277.   Vector v4(bas, ScalarList(3.4, 8.9, 0.9));
  278.   VectorEC veq1 = v1;
  279.   VectorEC veq2 = v2;
  280.   VectorEC veq3 = v3;
  281.   VectorEC veq4 = v4;
  282.   ASubSet mas("my asubset", v, GeObList(v1, v2, v3));
  283.  
  284.   APoint p1(fra, ScalarList(4.5, 9.2, 1.0));
  285.   APoint p2(fra, ScalarList(5.7, 1.3, 1.0));
  286.   APoint p3(fra, ScalarList(7.7, 8.2, 1.0));
  287.   Simplex sp("test simplex", a, GeObList(p1, p2, p3));
  288.  
  289.   PPoint pp1(hfr, ScalarList(2.4, 4.5, 7.8));
  290.   PPoint pp2(hfr, ScalarList(7.2, 3.9, 4.1));
  291.   PPoint pp3(hfr, ScalarList(5.7, 2.3, 9.1));
  292.   PPoint pp4(hfr, ScalarList(9.6, 8.4, 11.9));
  293.   PPoint pp5(hfr, ScalarList(8.1, 6.8, 16.9));
  294.   ASubSet masp("my asubset in p", p, pp1, GeObList(pp2, pp3));
  295.  
  296.   ProjectiveMap pm1(hfr, v.FullProjSet(), GeObList(veq1, veq2, veq3, veq4));
  297.   AffineMap am1(sp, mas, GeObList(v1, v2, v3));
  298.   AffineMap am2(sp, masp, GeObList(pp1, pp4, pp5));
  299.  
  300.   a.SetSpace(p, am2);
  301.   a.SetSpace(v, am1);
  302.  
  303. // Send a point around the map loop...
  304.   
  305.   Vector vt;
  306.   VectorEC veqt;
  307.   PPoint ppt;
  308.   AVector avt;
  309.   APoint apt;
  310.   AVector avto(fra, ScalarList(2.4, 6.7, 0.0)); 
  311.   APoint orig(fra, ScalarList(4.0, 2.3, 1.0));
  312.  
  313.   vt = orig;
  314.   veqt = 2 * vt;
  315.   ppt = veqt;
  316.   apt = ppt;
  317.   report(orig - apt);
  318.  
  319.   vt = orig;
  320.   ppt = vt;
  321.   apt = ppt;
  322.   report(orig - apt);
  323.  
  324.   ppt = orig;
  325.   vt = ppt;
  326.   apt = vt;
  327.   report(orig - apt);
  328.  
  329.   vt = avto;
  330.   avt = vt;
  331.   report(avto - avt);
  332.  
  333.   probe(a);
  334. }
  335.  
  336. // ***********************************************************************
  337. // LinkAPHaveLA
  338.  
  339. void test4(void)
  340. {
  341.   cout << "ENTERING TEST4\n";
  342.   VSpace v("Test vector space", 3, TRUE);
  343.   ASpace a("Test affine space", 2, TRUE);
  344.   PSpace p("Test projective space", 2);
  345.  
  346.   VBasis bas = v.StdBasis();
  347.   Frame fra = a.StdBasis();
  348.   HFrame hfr = p.StdBasis();
  349.  
  350.   Vector v1(bas, ScalarList(2.4, 5.6, 1.2));
  351.   Vector v2(bas, ScalarList(1.0, 6.2, 8.9));
  352.   Vector v3(bas, ScalarList(7.8, 3.3, 4.6));
  353.   Vector v4(bas, ScalarList(3.4, 8.9, 0.9));
  354.   VectorEC veq1 = v1;
  355.   VectorEC veq2 = v2;
  356.   VectorEC veq3 = v3;
  357.   VectorEC veq4 = v4;
  358.   ASubSet mas("my asubset", v, GeObList(v1, v2, v3));
  359.  
  360.   APoint p1(fra, ScalarList(4.5, 9.2, 1.0));
  361.   APoint p2(fra, ScalarList(5.7, 1.3, 1.0));
  362.   APoint p3(fra, ScalarList(7.7, 8.2, 1.0));
  363.   Simplex sp("test simplex", a, GeObList(p1, p2, p3));
  364.  
  365.   PPoint pp1(hfr, ScalarList(2.4, 4.5, 7.8));
  366.   PPoint pp2(hfr, ScalarList(7.2, 3.9, 4.1));
  367.   PPoint pp3(hfr, ScalarList(5.7, 2.3, 9.1));
  368.   PPoint pp4(hfr, ScalarList(9.6, 8.4, 11.9));
  369.   PPoint pp5(hfr, ScalarList(8.1, 6.8, 16.9));
  370.   ASubSet masp("my asubset in p", p, pp1, GeObList(pp2, pp3));
  371.  
  372.   ProjectiveMap pm1(hfr, v.FullProjSet(), GeObList(veq1, veq2, veq3, veq4));
  373.   AffineMap am1(sp, mas, GeObList(v1, v2, v3));
  374.   AffineMap am2(sp, masp, GeObList(pp1, pp4, pp5));
  375.  
  376.   a.SetSpace(v, am1);
  377.   a.SetSpace(p, am2);
  378.  
  379. // Send a point around the map loop...
  380.   
  381.   Vector vt;
  382.   VectorEC veqt;
  383.   PPoint ppt;
  384.   AVector avt;
  385.   APoint apt;
  386.   AVector avto(fra, ScalarList(2.4, 6.7, 0.0)); 
  387.   APoint orig(fra, ScalarList(4.0, 2.3, 1.0));
  388.  
  389.   vt = orig;
  390.   veqt = 2 * vt;
  391.   ppt = veqt;
  392.   apt = ppt;
  393.   report(orig - apt);
  394.  
  395.   vt = orig;
  396.   ppt = vt;
  397.   apt = ppt;
  398.   report(orig - apt);
  399.  
  400.   ppt = orig;
  401.   vt = ppt;
  402.   apt = vt;
  403.   report(orig - apt);
  404.  
  405.   vt = avto;
  406.   avt = vt;
  407.   report(avto - avt);
  408.  
  409.   probe(a);
  410. }
  411.  
  412. // ***********************************************************************
  413. // LinkLPHaveLA
  414.  
  415. void test5(void)
  416. {
  417.   cout << "ENTERING TEST5\n";
  418.   VSpace v("Test vector space", 3, TRUE);
  419.   ASpace a("Test affine space", 2, TRUE);
  420.   PSpace p("Test projective space", 2);
  421.  
  422.   VBasis bas = v.StdBasis();
  423.   Frame fra = a.StdBasis();
  424.   HFrame hfr = p.StdBasis();
  425.  
  426.   Vector v1(bas, ScalarList(2.4, 5.6, 1.2));
  427.   Vector v2(bas, ScalarList(1.0, 6.2, 8.9));
  428.   Vector v3(bas, ScalarList(7.8, 3.3, 4.6));
  429.   Vector v4(bas, ScalarList(3.4, 8.9, 0.9));
  430.   VectorEC veq1 = v1;
  431.   VectorEC veq2 = v2;
  432.   VectorEC veq3 = v3;
  433.   VectorEC veq4 = v4;
  434.   ASubSet mas("my asubset", v, GeObList(v1, v2, v3));
  435.  
  436.   APoint p1(fra, ScalarList(4.5, 9.2, 1.0));
  437.   APoint p2(fra, ScalarList(5.7, 1.3, 1.0));
  438.   APoint p3(fra, ScalarList(7.7, 8.2, 1.0));
  439.   Simplex sp("test simplex", a, GeObList(p1, p2, p3));
  440.  
  441.   PPoint pp1(hfr, ScalarList(2.4, 4.5, 7.8));
  442.   PPoint pp2(hfr, ScalarList(7.2, 3.9, 4.1));
  443.   PPoint pp3(hfr, ScalarList(5.7, 2.3, 9.1));
  444.   PPoint pp4(hfr, ScalarList(9.6, 8.4, 11.9));
  445.   PPoint pp5(hfr, ScalarList(8.1, 6.8, 16.9));
  446.   ASubSet masp("my asubset in p", p, pp1, GeObList(pp2, pp3));
  447.  
  448.   ProjectiveMap pm1(hfr, v.FullProjSet(), GeObList(veq1, veq2, veq3, veq4));
  449.   AffineMap am1(sp, mas, GeObList(v1, v2, v3));
  450.   AffineMap am2(sp, masp, GeObList(pp1, pp4, pp5));
  451.  
  452.   a.SetSpace(v, am1);
  453.   p.SetSpace(v, pm1);
  454.  
  455. // Send a point around the map loop...
  456.   
  457.   Vector vt;
  458.   VectorEC veqt;
  459.   PPoint ppt;
  460.   AVector avt;
  461.   APoint apt;
  462.   AVector avto(fra, ScalarList(2.4, 6.7, 0.0)); 
  463.   APoint orig(fra, ScalarList(4.0, 2.3, 1.0));
  464.  
  465.   vt = orig;
  466.   veqt = 2 * vt;
  467.   ppt = veqt;
  468.   apt = ppt;
  469.   report(orig - apt);
  470.  
  471.   vt = orig;
  472.   ppt = vt;
  473.   apt = ppt;
  474.   report(orig - apt);
  475.  
  476.   ppt = orig;
  477.   vt = ppt;
  478.   apt = vt;
  479.   report(orig - apt);
  480.  
  481.   vt = avto;
  482.   avt = vt;
  483.   report(avto - avt);
  484.  
  485.   probe(a);
  486. }
  487.  
  488. // ***********************************************************************
  489. // LinkLPHaveAP
  490.  
  491. void test6(void)
  492. {
  493.   cout << "ENTERING TEST6\n";
  494.   VSpace v("Test vector space", 3, TRUE);
  495.   ASpace a("Test affine space", 2, TRUE);
  496.   PSpace p("Test projective space", 2);
  497.  
  498.   VBasis bas = v.StdBasis();
  499.   Frame fra = a.StdBasis();
  500.   HFrame hfr = p.StdBasis();
  501.  
  502.   Vector v1(bas, ScalarList(2.4, 5.6, 1.2));
  503.   Vector v2(bas, ScalarList(1.0, 6.2, 8.9));
  504.   Vector v3(bas, ScalarList(7.8, 3.3, 4.6));
  505.   Vector v4(bas, ScalarList(3.4, 8.9, 0.9));
  506.   VectorEC veq1 = v1;
  507.   VectorEC veq2 = v2;
  508.   VectorEC veq3 = v3;
  509.   VectorEC veq4 = v4;
  510.   ASubSet mas("my asubset", v, GeObList(v1, v2, v3));
  511.  
  512.   APoint p1(fra, ScalarList(4.5, 9.2, 1.0));
  513.   APoint p2(fra, ScalarList(5.7, 1.3, 1.0));
  514.   APoint p3(fra, ScalarList(7.7, 8.2, 1.0));
  515.   Simplex sp("test simplex", a, GeObList(p1, p2, p3));
  516.  
  517.   PPoint pp1(hfr, ScalarList(2.4, 4.5, 7.8));
  518.   PPoint pp2(hfr, ScalarList(7.2, 3.9, 4.1));
  519.   PPoint pp3(hfr, ScalarList(5.7, 2.3, 9.1));
  520.   PPoint pp4(hfr, ScalarList(9.6, 8.4, 11.9));
  521.   PPoint pp5(hfr, ScalarList(8.1, 6.8, 16.9));
  522.   ASubSet masp("my asubset in p", p, pp1, GeObList(pp2, pp3));
  523.  
  524.   ProjectiveMap pm1(hfr, v.FullProjSet(), GeObList(veq1, veq2, veq3, veq4));
  525.   AffineMap am1(sp, mas, GeObList(v1, v2, v3));
  526.   AffineMap am2(sp, masp, GeObList(pp1, pp4, pp5));
  527.  
  528.   a.SetSpace(p, am2);
  529.   p.SetSpace(v, pm1);
  530.  
  531. // Send a point around the map loop...
  532.   
  533.   Vector vt;
  534.   VectorEC veqt;
  535.   PPoint ppt;
  536.   AVector avt;
  537.   APoint apt;
  538.   AVector avto(fra, ScalarList(2.4, 6.7, 0.0)); 
  539.   APoint orig(fra, ScalarList(4.0, 2.3, 1.0));
  540.  
  541.   vt = orig;
  542.   veqt = 2 * vt;
  543.   ppt = veqt;
  544.   apt = ppt;
  545.   report(orig - apt);
  546.  
  547.   vt = orig;
  548.   ppt = vt;
  549.   apt = ppt;
  550.   report(orig - apt);
  551.  
  552.   ppt = orig;
  553.   vt = ppt;
  554.   apt = vt;
  555.   report(orig - apt);
  556.  
  557.   vt = avto;
  558.   avt = vt;
  559.   report(avto - avt);
  560.  
  561.   probe(a);
  562. }
  563.  
  564. // ***********************************************************************
  565. // LinkLAHaveLP
  566.  
  567. void test7(void)
  568. {
  569.   cout << "ENTERING TEST7\n";
  570.   VSpace v("Test vector space", 3, TRUE);
  571.   PSpace p("Test projective space", v);
  572.   ASpace a("Test affine space", TRUE, v);
  573.  
  574.   VBasis bas = v.StdBasis();
  575.   Frame fra = a.StdBasis();
  576.   HFrame hfr = p.StdBasis();
  577.  
  578. // Send a point around the map loop...
  579.   
  580.   Vector vt;
  581.   VectorEC veqt;
  582.   PPoint ppt;
  583.   AVector avt;
  584.   APoint apt;
  585.   AVector avto(fra, ScalarList(2.4, 6.7, 0.0)); 
  586.   APoint orig(fra, ScalarList(4.0, 2.3, 1.0));
  587.  
  588.   vt = orig;
  589.   veqt = 2 * vt;
  590.   ppt = veqt;
  591.   apt = ppt;
  592.   report(orig - apt);
  593.  
  594.   vt = orig;
  595.   ppt = vt;
  596.   apt = ppt;
  597.   report(orig - apt);
  598.  
  599.   ppt = orig;
  600.   vt = ppt;
  601.   apt = vt;
  602.   report(orig - apt);
  603.  
  604.   vt = avto;
  605.   avt = vt;
  606.   report(avto - avt);
  607.  
  608.   probe(a);
  609. }
  610.  
  611. // ***********************************************************************
  612. // LinkAPHaveLP
  613.  
  614. void test8(void)
  615. {
  616.   cout << "ENTERING TEST8\n";
  617.   PSpace p("Test projective space", 2);
  618.   VSpace v("Test vector space", TRUE, p);
  619.   ASpace a("Test affine space", TRUE, p);
  620.  
  621.   VBasis bas = v.StdBasis();
  622.   Frame fra = a.StdBasis();
  623.   HFrame hfr = p.StdBasis();
  624.  
  625. // Send a point around the map loop...
  626.   
  627.   Vector vt;
  628.   VectorEC veqt;
  629.   PPoint ppt;
  630.   AVector avt;
  631.   APoint apt;
  632.   AVector avto(fra, ScalarList(2.4, 6.7, 0.0)); 
  633.   APoint orig(fra, ScalarList(4.0, 2.3, 1.0));
  634.  
  635.   vt = orig;
  636.   veqt = 2 * vt;
  637.   ppt = veqt;
  638.   apt = ppt;
  639.   report(orig - apt);
  640.  
  641.   vt = orig;
  642.   ppt = vt;
  643.   apt = ppt;
  644.   report(orig - apt);
  645.  
  646.   ppt = orig;
  647.   vt = ppt;
  648.   apt = vt;
  649.   report(orig - apt);
  650.  
  651.   vt = avto;
  652.   avt = vt;
  653.   report(avto - avt);
  654.  
  655.   probe(a);
  656. }
  657. // ***********************************************************************
  658. // LinkLAHaveAP
  659.  
  660. void test9(void)
  661. {
  662.   cout << "ENTERING TEST9\n";
  663.   PSpace p("Test projective space", 2);
  664.   ASpace a("Test affine space", TRUE, p);
  665.   VSpace v("Test vector space", TRUE, a);
  666.  
  667.   VBasis bas = v.StdBasis();
  668.   Frame fra = a.StdBasis();
  669.   HFrame hfr = p.StdBasis();
  670.  
  671. // Send a point around the map loop...
  672.   
  673.   Vector vt;
  674.   VectorEC veqt;
  675.   PPoint ppt;
  676.   AVector avt;
  677.   APoint apt;
  678.   AVector avto(fra, ScalarList(2.4, 6.7, 0.0)); 
  679.   APoint orig(fra, ScalarList(4.0, 2.3, 1.0));
  680.  
  681.   vt = orig;
  682.   veqt = 2 * vt;
  683.   ppt = veqt;
  684.   apt = ppt;
  685.   report(orig - apt);
  686.  
  687.   vt = orig;
  688.   ppt = vt;
  689.   apt = ppt;
  690.   report(orig - apt);
  691.  
  692.   ppt = orig;
  693.   vt = ppt;
  694.   apt = vt;
  695.   report(orig - apt);
  696.  
  697.   vt = avto;
  698.   avt = vt;
  699.   report(avto - avt);
  700.  
  701.   probe(a);
  702. }
  703. // ***********************************************************************
  704. // LinkAPHaveLA
  705.  
  706. void test10(void)
  707. {
  708.   cout << "ENTERING TEST10\n";
  709.   VSpace v("Test vector space", 3, TRUE);
  710.   ASpace a("Test affine space", TRUE, v);
  711.   PSpace p("Test projective space", a);
  712.  
  713.   VBasis bas = v.StdBasis();
  714.   Frame fra = a.StdBasis();
  715.   HFrame hfr = p.StdBasis();
  716.  
  717. // Send a point around the map loop...
  718.   
  719.   Vector vt;
  720.   VectorEC veqt;
  721.   PPoint ppt;
  722.   AVector avt;
  723.   APoint apt;
  724.   AVector avto(fra, ScalarList(2.4, 6.7, 0.0)); 
  725.   APoint orig(fra, ScalarList(4.0, 2.3, 1.0));
  726.  
  727.   vt = orig;
  728.   veqt = 2 * vt;
  729.   ppt = veqt;
  730.   apt = ppt;
  731.   report(orig - apt);
  732.  
  733.   vt = orig;
  734.   ppt = vt;
  735.   apt = ppt;
  736.   report(orig - apt);
  737.  
  738.   ppt = orig;
  739.   vt = ppt;
  740.   apt = vt;
  741.   report(orig - apt);
  742.  
  743.   vt = avto;
  744.   avt = vt;
  745.   report(avto - avt);
  746.  
  747.   probe(a);
  748. }
  749. // ***********************************************************************
  750. // LinkLPHaveLA
  751.  
  752. void test11(void)
  753. {
  754.   cout << "ENTERING TEST11\n";
  755.   ASpace a("Test affine space", 2, TRUE);
  756.   VSpace v("Test vector space", TRUE, a);
  757.   PSpace p("Test projective space", v);
  758.  
  759.   VBasis bas = v.StdBasis();
  760.   Frame fra = a.StdBasis();
  761.   HFrame hfr = p.StdBasis();
  762.  
  763. // Send a point around the map loop...
  764.   
  765.   Vector vt;
  766.   VectorEC veqt;
  767.   PPoint ppt;
  768.   AVector avt;
  769.   APoint apt;
  770.   AVector avto(fra, ScalarList(2.4, 6.7, 0.0)); 
  771.   APoint orig(fra, ScalarList(4.0, 2.3, 1.0));
  772.  
  773.   vt = orig;
  774.   veqt = 2 * vt;
  775.   ppt = veqt;
  776.   apt = ppt;
  777.   report(orig - apt);
  778.  
  779.   vt = orig;
  780.   ppt = vt;
  781.   apt = ppt;
  782.   report(orig - apt);
  783.  
  784.   ppt = orig;
  785.   vt = ppt;
  786.   apt = vt;
  787.   report(orig - apt);
  788.  
  789.   vt = avto;
  790.   avt = vt;
  791.   report(avto - avt);
  792.  
  793.   probe(a);
  794. }
  795. // ***********************************************************************
  796. // LinkLPHaveAP
  797.  
  798. void test12(void)
  799. {
  800.   cout << "ENTERING TEST12\n";
  801.   ASpace a("Test affine space", 2, TRUE);
  802.   PSpace p("Test projective space", a);
  803.   VSpace v("Test vector space", TRUE, p);
  804.  
  805.   VBasis bas = v.StdBasis();
  806.   Frame fra = a.StdBasis();
  807.   HFrame hfr = p.StdBasis();
  808.  
  809. // Send a point around the map loop...
  810.   
  811.   Vector vt;
  812.   VectorEC veqt;
  813.   PPoint ppt;
  814.   AVector avt;
  815.   APoint apt;
  816.   AVector avto(fra, ScalarList(2.4, 6.7, 0.0)); 
  817.   APoint orig(fra, ScalarList(4.0, 2.3, 1.0));
  818.  
  819.   vt = orig;
  820.   veqt = 2 * vt;
  821.   ppt = veqt;
  822.   apt = ppt;
  823.   report(orig - apt);
  824.  
  825.   vt = orig;
  826.   ppt = vt;
  827.   apt = ppt;
  828.   report(orig - apt);
  829.  
  830.   ppt = orig;
  831.   vt = ppt;
  832.   apt = vt;
  833.   report(orig - apt);
  834.  
  835.   vt = avto;
  836.   avt = vt;
  837.   report(avto - avt);
  838.  
  839.   probe(a);
  840. }
  841.  
  842. // ***********************************************************************
  843.  
  844. void truth(Boolean res, Boolean expect)
  845. {
  846.   if (res == expect) { 
  847.     cout << "Success\n";
  848.   } else {
  849.     cout << "Failure\n";
  850.   }    
  851. }
  852.  
  853. // ***********************************************************************
  854. // Test for space gets, relations, space tests, native types, duals
  855.  
  856. void test13(void)
  857. {
  858. //
  859. // Manually build a set:
  860. //
  861.  
  862.   cout << "ENTERING TEST13\n";
  863.   VSpace v("Test vector space", 3, TRUE);
  864.   ASpace a("Test affine space", 2, TRUE);
  865.   PSpace p("Test projective space", 2);
  866.  
  867.   VBasis bas = v.StdBasis();
  868.   Frame fra = a.StdBasis();
  869.   HFrame hfr = p.StdBasis();
  870.  
  871.   Vector v1(bas, ScalarList(2.4, 5.6, 1.2));
  872.   Vector v2(bas, ScalarList(1.0, 6.2, 8.9));
  873.   Vector v3(bas, ScalarList(7.8, 3.3, 4.6));
  874.   Vector v4(bas, ScalarList(3.4, 8.9, 0.9));
  875.   VectorEC veq1 = v1;
  876.   VectorEC veq2 = v2;
  877.   VectorEC veq3 = v3;
  878.   VectorEC veq4 = v4;
  879.   ASubSet mas("my asubset", v, GeObList(v1, v2, v3));
  880.  
  881.   APoint p1(fra, ScalarList(4.5, 9.2, 1.0));
  882.   APoint p2(fra, ScalarList(5.7, 1.3, 1.0));
  883.   APoint p3(fra, ScalarList(7.7, 8.2, 1.0));
  884.   Simplex sp("test simplex", a, GeObList(p1, p2, p3));
  885.  
  886.   PPoint pp1(hfr, ScalarList(2.4, 4.5, 7.8));
  887.   PPoint pp2(hfr, ScalarList(7.2, 3.9, 4.1));
  888.   PPoint pp3(hfr, ScalarList(5.7, 2.3, 9.1));
  889.   PPoint pp4(hfr, ScalarList(9.6, 8.4, 11.9));
  890.   PPoint pp5(hfr, ScalarList(8.1, 6.8, 16.9));
  891.   ASubSet masp("my asubset in p", p, pp1, GeObList(pp2, pp3));
  892.  
  893.   ProjectiveMap pm1(hfr, v.FullProjSet(), GeObList(veq1, veq2, veq3, veq4));
  894.   AffineMap am1(sp, mas, GeObList(v1, v2, v3));
  895.   AffineMap am2(sp, masp, GeObList(pp1, pp4, pp5));
  896.  
  897.   p.SetSpace(v, pm1);
  898.   a.SetSpace(v, am1);
  899.  
  900. // The following should all be as indicated:
  901.  
  902.   truth(a.HasSpace(TANGENT), FALSE);
  903.   truth(v.HasSpace(TANG_DUAL), FALSE);
  904.   truth(p.HasSpace(LIN_DUAL), FALSE);
  905.   truth(p.HasSpace(LINEARIZATION), TRUE);
  906.   truth(v.HasSpace(AFFINE), TRUE);
  907.   truth(a.HasSpace(PROJECT_COMP), TRUE);
  908.  
  909. // Get some spaces, test equal and not equal:
  910.  
  911.   Space td = p.GetSpace(TANG_DUAL);
  912.   Space ld = td.GetSpace(LIN_DUAL);
  913.   Space t = ld.GetSpace(TANGENT);
  914.   Space s1 = td.GetSpace(AFFINE);
  915.   Space s2 = ld.GetSpace(PROJECT_COMP);
  916.   Space s3 = t.GetSpace(LINEARIZATION);
  917.   Space td2 = ld.GetSpace(TANG_DUAL);
  918.  
  919.   truth((s1 == a), TRUE);
  920.   truth((s2 == p), TRUE);
  921.   truth((s3 == v), TRUE);
  922.   truth((td == td2), TRUE);
  923.   truth((td != t), TRUE);
  924.   truth((a != s1), FALSE);
  925.  
  926.   truth((a.GetSpace(LINEARIZATION) == v), TRUE);
  927.   truth((p.GetSpace(TANGENT) == t), TRUE);
  928.   truth((v.GetSpace(TANG_DUAL) == td), TRUE);
  929.   truth((td.GetSpace(AFFINE) == a), TRUE);
  930.   truth((ld.GetSpace(PROJECT_COMP) == p), TRUE);
  931.   truth((t.GetSpace(LIN_DUAL) == ld), TRUE);
  932.  
  933. // Check SRel functions: 
  934.  
  935.   truth((a.ThisSpaceIs() == AFFINE), TRUE);
  936.   truth((p.ThisSpaceIs() == PROJECT_COMP), TRUE);
  937.   truth((v.ThisSpaceIs() == LINEARIZATION), TRUE);
  938.   truth((td.ThisSpaceIs() == TANG_DUAL), TRUE);
  939.   truth((ld.ThisSpaceIs() == LIN_DUAL), TRUE);
  940.   truth((t.ThisSpaceIs() == TANGENT), TRUE);
  941.  
  942.   VSpace odd("Odd space", 2, FALSE);
  943.  
  944.   truth((a.SpaceRelation(a) == SAME_SPACE), TRUE);
  945.   truth((p.SpaceRelation(odd) == NO_RELATION), TRUE);
  946.   truth((v.SpaceRelation(a) == AFFINE), TRUE);
  947.   truth((td.SpaceRelation(p) == PROJECT_COMP), TRUE);
  948.   truth((ld.SpaceRelation(td) == TANG_DUAL), TRUE);
  949.   truth((t.SpaceRelation(v) == LINEARIZATION), TRUE);
  950.  
  951. // Check native type functions:
  952.  
  953.   truth((a.NativeType() == AFF_POINT), TRUE);
  954.   truth((p.NativeType() == PROJ_POINT), TRUE);
  955.   truth((v.NativeType() == VECTOR), TRUE);
  956.   truth((td.NativeType() == VECTOR), TRUE);
  957.   truth((ld.NativeType() == VECTOR), TRUE);
  958.   truth((t.NativeType() == AFF_VECTOR), TRUE);
  959.  
  960. // Check dual functions:
  961.  
  962.   truth((v.Dual() == ld), TRUE);
  963.   truth((td.Dual() == t), TRUE);
  964.   truth((ld.Dual() == v), TRUE);
  965.   truth((t.Dual() == td), TRUE);
  966. }
  967.  
  968. // ***********************************************************************
  969. // Test for points at infinity, standard subsets:
  970.  
  971. void test14(void)
  972. {
  973.   int i;
  974. //
  975. // Manually build a set:
  976. //
  977.   cout << "ENTERING TEST14\n";
  978.   VSpace v("Test vector space", 3, TRUE);
  979.   ASpace a("Test affine space", 2, TRUE);
  980.   PSpace p("Test projective space", 2);
  981.  
  982. //
  983. // Bare projective spaces do not have points at infinity:
  984. //
  985.  
  986.   GeObList pts = p.PtsAtInfinity();
  987.   truth((pts.Length() == 0), TRUE);
  988.  
  989.   VBasis bas = v.StdBasis();
  990.   Frame fra = a.StdBasis();
  991.   HFrame hfr = p.StdBasis();
  992.   Simplex simp = a.StdSimplex();
  993.  
  994.   Vector v1(bas, ScalarList(2.4, 5.6, 1.2));
  995.   Vector v2(bas, ScalarList(1.0, 6.2, 8.9));
  996.   Vector v3(bas, ScalarList(7.8, 3.3, 4.6));
  997.   Vector v4(bas, ScalarList(3.4, 8.9, 0.9));
  998.   VectorEC veq1 = v1;
  999.   VectorEC veq2 = v2;
  1000.   VectorEC veq3 = v3;
  1001.   VectorEC veq4 = v4;
  1002.   ASubSet mas("my asubset", v, GeObList(v1, v2, v3));
  1003.  
  1004.   APoint p1(fra, ScalarList(4.5, 9.2, 1.0));
  1005.   APoint p2(fra, ScalarList(5.7, 1.3, 1.0));
  1006.   APoint p3(fra, ScalarList(7.7, 8.2, 1.0));
  1007.   Simplex sp("test simplex", a, GeObList(p1, p2, p3));
  1008.  
  1009.   PPoint pp1(hfr, ScalarList(2.4, 4.5, 7.8));
  1010.   PPoint pp2(hfr, ScalarList(7.2, 3.9, 4.1));
  1011.   PPoint pp3(hfr, ScalarList(5.7, 2.3, 9.1));
  1012.   PPoint pp4(hfr, ScalarList(9.6, 8.4, 11.9));
  1013.   PPoint pp5(hfr, ScalarList(8.1, 6.8, 16.9));
  1014.   ASubSet masp("my asubset in p", p, pp1, GeObList(pp2, pp3));
  1015.  
  1016.   ProjectiveMap pm1(hfr, v.FullProjSet(), GeObList(veq1, veq2, veq3, veq4));
  1017.   AffineMap am1(sp, mas, GeObList(v1, v2, v3));
  1018.   AffineMap am2(sp, masp, GeObList(pp1, pp4, pp5));
  1019.  
  1020.   p.SetSpace(v, pm1);
  1021.   a.SetSpace(v, am1);
  1022.  
  1023. //
  1024. // Get the points at infinity.  Check to make sure that they are not
  1025. // in the standard affine subset of the space:
  1026. //
  1027.  
  1028.   pts = p.PtsAtInfinity();
  1029.   int len = pts.Length();
  1030.   ASubSet stda = p.StdAffineSubset();
  1031.  
  1032.   for (i = 0; i < len; i++) {
  1033.     truth(stda.IsIn(pts[i]), FALSE);
  1034.   }
  1035.  
  1036. //
  1037. // Everybody in a basis had better be in the full set:
  1038. //
  1039.  
  1040.   len = v.Dim();
  1041.   VSubSet vfull = v.FullSet();
  1042.   for (i = 0; i < len; i++) {
  1043.     truth(vfull.IsIn(bas[i]), TRUE);
  1044.   }
  1045.  
  1046.   len = a.Dim() + 1;
  1047.   ASubSet afull = a.FullSet();
  1048.   for (i = 0; i < len; i++) {
  1049.     truth(afull.IsIn(simp[i]), TRUE);
  1050.   }
  1051.  
  1052.   len = p.Dim() + 2;
  1053.   PSubSet pfull = p.FullSet();
  1054.   for (i = 0; i < len; i++) {
  1055.     truth(pfull.IsIn(hfr[i]), TRUE);
  1056.   }
  1057.  
  1058. //
  1059. // All VectorEC derived from a basis had better be in the
  1060. // full projective set:
  1061. //
  1062.  
  1063.   len = v.Dim();
  1064.   PSubSet vfullpr = v.FullProjSet();
  1065.   for (i = 0; i < len; i++) {
  1066.     truth(vfullpr.IsIn(VectorEC(bas[i])), TRUE);
  1067.   }
  1068.  
  1069.   VSpace t = a.GetSpace(TANGENT);
  1070.   VBasis tbas = t.StdBasis();
  1071.  
  1072.   len = t.Dim();
  1073.   PSubSet tfullpr = t.FullProjSet();
  1074.   for (i = 0; i < len; i++) {
  1075.     truth(tfullpr.IsIn(AVectorEC(tbas[i])), TRUE);
  1076.   }
  1077.  
  1078.   len = p.Dim() + 2;
  1079.   PSubSet pfullpr = p.FullProjSet();
  1080.   for (i = 0; i < len; i++) {
  1081.     truth(pfullpr.IsIn(hfr[i]), TRUE);
  1082.   }
  1083.  
  1084. //
  1085. // Points in affine space, when cast, had better be in the
  1086. // std affine subset.  Points and infinity (checked above)
  1087. // and cast affine vectors are not:
  1088. //
  1089.  
  1090.   len = a.Dim() + 1;
  1091.   ASubSet vsas = v.StdAffineSubset();
  1092.   for (i = 0; i < len; i++) {
  1093.     truth(vsas.IsIn(Vector(simp[i])), TRUE);
  1094.   }
  1095.   for (i = 0; i < t.Dim(); i++) {
  1096.     truth(vsas.IsIn(Vector(tbas[i])), FALSE);
  1097.   }
  1098.  
  1099.   ASubSet asas = a.StdAffineSubset();
  1100.   for (i = 0; i < len; i++) {
  1101.     truth(asas.IsIn(simp[i]), TRUE);
  1102.   }
  1103.  
  1104.   ASubSet psas = p.StdAffineSubset();
  1105.   for (i = 0; i < len; i++) {
  1106.     truth(psas.IsIn(PPoint(simp[i])), TRUE);
  1107.   }
  1108.  
  1109. }
  1110.  
  1111. // ***********************************************************************
  1112. // Test for standard maps.  This has already been given a pretty
  1113. // extensive workout during tests of geobs.
  1114.  
  1115. void test15(void)
  1116. {
  1117. //
  1118. // Manually build a set:
  1119. //
  1120.   cout << "ENTERING TEST15\n";
  1121.   VSpace v("Test vector space", 3, TRUE);
  1122.   ASpace a("Test affine space", 2, TRUE);
  1123.   PSpace p("Test projective space", 2);
  1124.  
  1125.   VBasis bas = v.StdBasis();
  1126.   Frame fra = a.StdBasis();
  1127.   HFrame hfr = p.StdBasis();
  1128.   Simplex simp = a.StdSimplex();
  1129.  
  1130.   Vector v1(bas, ScalarList(2.4, 5.6, 1.2));
  1131.   Vector v2(bas, ScalarList(1.0, 6.2, 8.9));
  1132.   Vector v3(bas, ScalarList(7.8, 3.3, 4.6));
  1133.   Vector v4(bas, ScalarList(3.4, 8.9, 0.9));
  1134.   VectorEC veq1 = v1;
  1135.   VectorEC veq2 = v2;
  1136.   VectorEC veq3 = v3;
  1137.   VectorEC veq4 = v4;
  1138.   ASubSet mas("my asubset", v, GeObList(v1, v2, v3));
  1139.  
  1140.   APoint p1(fra, ScalarList(4.5, 9.2, 1.0));
  1141.   APoint p2(fra, ScalarList(5.7, 1.3, 1.0));
  1142.   APoint p3(fra, ScalarList(7.7, 8.2, 1.0));
  1143.   Simplex sp("test simplex", a, GeObList(p1, p2, p3));
  1144.  
  1145.   PPoint pp1(hfr, ScalarList(2.4, 4.5, 7.8));
  1146.   PPoint pp2(hfr, ScalarList(7.2, 3.9, 4.1));
  1147.   PPoint pp3(hfr, ScalarList(5.7, 2.3, 9.1));
  1148.   PPoint pp4(hfr, ScalarList(9.6, 8.4, 11.9));
  1149.   PPoint pp5(hfr, ScalarList(8.1, 6.8, 16.9));
  1150.   ASubSet masp("my asubset in p", p, pp1, GeObList(pp2, pp3));
  1151.  
  1152.   ProjectiveMap pm1(hfr, v.FullProjSet(), GeObList(veq1, veq2, veq3, veq4));
  1153.   AffineMap am1(sp, mas, GeObList(v1, v2, v3));
  1154.   AffineMap am2(sp, masp, GeObList(pp1, pp4, pp5));
  1155.  
  1156.   p.SetSpace(v, pm1);
  1157.   a.SetSpace(v, am1);
  1158.  
  1159. //
  1160. // Get a whole bunch of standard maps
  1161. //
  1162.  
  1163.   LinearMap vtot = v.LinearMapTo(TANGENT);
  1164.   VSpace t = v.GetSpace(TANGENT);
  1165.   LinearMap ttov = t.LinearMapTo(LINEARIZATION);
  1166.   AffineMap ptov = p.AffineMapTo(LINEARIZATION);
  1167.   AffineMap vtop = v.AffineMapTo(PROJECT_COMP);
  1168.   AffineMap atov = a.AffineMapTo(LINEARIZATION);
  1169.   AffineMap vtoa = v.AffineMapTo(AFFINE);
  1170.   AffineMap atop = a.AffineMapTo(PROJECT_COMP);
  1171.   AffineMap ptoa = p.AffineMapTo(AFFINE);
  1172.   ProjectiveMap ptovp = p.ProjectiveMapTo(LINEARIZATION);
  1173.   ProjectiveMap vtopp = v.ProjectiveMapTo(PROJECT_COMP);
  1174.  
  1175.   Vector vt;
  1176.   VectorEC veqt;
  1177.   PPoint ppt;
  1178.   AVector avt;
  1179.   APoint apt;
  1180.   AVector avto(fra, ScalarList(2.4, 6.7, 0.0)); 
  1181.   APoint orig(fra, ScalarList(4.0, 2.3, 1.0));
  1182.  
  1183.   vt = atov(orig);
  1184.  
  1185. // g++ 1.37.1 has problems with the following chained virtual function:
  1186. // veqt = (2 * vt).MapTo(VEC_EC);
  1187. // so:
  1188.  
  1189.   Vector temp = 2 * vt;
  1190.   veqt = temp.MapTo(VEC_EC);
  1191.  
  1192.   ppt = vtopp(veqt);
  1193.   apt = ptoa(ppt);
  1194.   report(orig - apt);
  1195.  
  1196.   vt = atov(orig);
  1197.   ppt = vtop(vt);
  1198.   apt = ptoa(ppt);
  1199.   report(orig - apt);
  1200.  
  1201.   ppt = atop(orig);
  1202.   vt = ptov(ppt);
  1203.   apt = vtoa(vt);
  1204.   report(orig - apt);
  1205.  
  1206.   vt = ttov(avto);
  1207.   avt = vtot(vt);
  1208.   report(avto - avt);
  1209.  
  1210. }
  1211.  
  1212. // ***********************************************************************
  1213. // Test for Euclidean stuff:
  1214.  
  1215. void test16(void)
  1216. {
  1217.   cout << "ENTERING TEST16\n";
  1218.   VSpace vs2 = VSpace("vs2", 2, TRUE);
  1219.   VSpace vs3 = VSpace("vs3", 3, TRUE);
  1220.   VSpace vs4 = VSpace("vs4", 4, TRUE);
  1221.  
  1222.   ASpace as2 = ASpace("as2", 2, TRUE);
  1223.   ASpace as3 = ASpace("as3", 3, TRUE);
  1224.   ASpace as4 = ASpace("as4", 4, TRUE);
  1225.  
  1226.   VSpace t2 = as2.GetSpace(TANGENT);
  1227.   VSpace t3 = as3.GetSpace(TANGENT);
  1228.   VSpace t4 = as4.GetSpace(TANGENT);
  1229.  
  1230.   truth(vs2.IsEuclidean(), TRUE);
  1231.   truth(vs3.IsEuclidean(), TRUE);
  1232.   truth(vs4.IsEuclidean(), TRUE);
  1233.   truth(as2.IsEuclidean(), TRUE);
  1234.   truth(as3.IsEuclidean(), TRUE);
  1235.   truth(as4.IsEuclidean(), TRUE);
  1236.   truth(t2.IsEuclidean(), TRUE);
  1237.   truth(t3.IsEuclidean(), TRUE);
  1238.   truth(t4.IsEuclidean(), TRUE);
  1239.  
  1240.   MLM vs2ip = vs2.InnerProduct();
  1241.   MLM vs3ip = vs3.InnerProduct();
  1242.   MLM vs4ip = vs4.InnerProduct();
  1243.   MLM t2ip = t2.InnerProduct();
  1244.   MLM t3ip = t3.InnerProduct();
  1245.   MLM t4ip = t4.InnerProduct();
  1246.  
  1247.   MLM vs2cp = vs2.CrossProduct();
  1248.   MLM vs3cp = vs3.CrossProduct();
  1249.   MLM vs4cp = vs4.CrossProduct();
  1250.   MLM t2cp = t2.CrossProduct();
  1251.   MLM t3cp = t3.CrossProduct();
  1252.   MLM t4cp = t4.CrossProduct();
  1253.  
  1254. //
  1255. // Test the functions:
  1256. //
  1257.  
  1258.   VBasis bas2 = vs2.StdBasis();
  1259.   VBasis bas3 = vs3.StdBasis();
  1260.   VBasis bas4 = vs4.StdBasis();
  1261.  
  1262.   Vector v2a(bas2, ScalarList(2.4, 1.2));
  1263.   Vector v2b(bas2, ScalarList(6.2, 8.9));
  1264.  
  1265.   Vector v3a(bas3, ScalarList(2.4, 5.6, 1.2));
  1266.   Vector v3b(bas3, ScalarList(1.0, 6.2, 8.9));
  1267.  
  1268.   Vector v4a(bas4, ScalarList(2.4, 5.6, 1.2, 3.6));
  1269.   Vector v4b(bas4, ScalarList(7.8, 3.3, 4.6, 7.2));
  1270.   Vector v4c(bas4, ScalarList(3.4, 8.9, 0.9, 1.5));
  1271.  
  1272.   Scalar res = vs2ip(GeObList(v2a, v2b)).ToScalar();
  1273.   cout << res << "\n";
  1274.   res = vs3ip(GeObList(v3a, v3b)).ToScalar();
  1275.   cout << res << "\n";
  1276.   res = vs4ip(GeObList(v4a, v4b)).ToScalar();
  1277.   cout << res << "\n";
  1278.  
  1279.   Vector resv = vs2cp(GeObList(v2a));
  1280.   cout << resv << "\n";
  1281.   res = vs2ip(GeObList(v2a, resv)).ToScalar();;
  1282.   cout << res << "\n";  
  1283.   resv = vs2cp(GeObList(bas2[0]));
  1284.   cout << resv << "\n";
  1285.  
  1286.   resv = vs3cp(GeObList(v3a, v3b));
  1287.   cout << resv << "\n";
  1288.   res = vs3ip(GeObList(v3a, resv)).ToScalar();
  1289.   cout << res << "\n";
  1290.   res = vs3ip(GeObList(v3b, resv)).ToScalar();
  1291.   cout << res << "\n";
  1292.   resv = vs3cp(GeObList(bas3[0], bas3[1]));
  1293.   cout << resv << "\n";
  1294.  
  1295.   resv = vs4cp(GeObList(v4a, v4b, v4c));
  1296.   cout << resv << "\n";
  1297.   res = vs4ip(GeObList(v4a, resv)).ToScalar();
  1298.   cout << res << "\n";
  1299.   res = vs4ip(GeObList(v4b, resv)).ToScalar();
  1300.   cout << res << "\n";
  1301.   res = vs4ip(GeObList(v4c, resv)).ToScalar();
  1302.   cout << res << "\n";
  1303.   resv = vs4cp(GeObList(v4a, v4c, v4b));
  1304.   cout << resv << "\n";
  1305.   resv = vs4cp(GeObList(v4c, v4a, v4b));
  1306.   cout << resv << "\n";
  1307.   resv = vs4cp(GeObList(bas4[0], bas4[1], bas4[2]));
  1308.   cout << resv << "\n";
  1309. }
  1310.  
  1311. // ***********************************************************************
  1312. // Test automatic space creation 
  1313.  
  1314. void test17(void)
  1315. {
  1316.   cout << "ENTERING TEST17\n";
  1317.   VSpace v = VSpace("test vspace", 3, TRUE);
  1318.   PSpace p = v.GetSpace(PROJECT_COMP);
  1319.   VSpace td = p.GetSpace(TANG_DUAL);
  1320.   ASpace a = td.GetSpace(AFFINE);
  1321.   VSpace t = p.GetSpace(TANGENT);
  1322.   VSpace vd = p.GetSpace(LIN_DUAL);
  1323.  
  1324.   probe(a);
  1325. }
  1326.  
  1327. // ***********************************************************************
  1328. // Test space lists and cartesian product space creation
  1329.  
  1330. void test18(void)
  1331. {
  1332.   cout << "ENTERING TEST18\n";
  1333.   ASpace a = ASpace("aspace", 1, TRUE);
  1334.   ASpace b = ASpace("bspace", 2, FALSE);
  1335.   ASpace c = ASpace("cspace", 2, TRUE);
  1336.   ASpace d = ASpace("dspace", 3, TRUE);
  1337.   ASpace e = ASpace("espace", 1, TRUE);
  1338.   SpaceList foo1(a, b, c);
  1339.   SpaceList foo2(2);
  1340.   SpaceList foo;
  1341.   foo2[0] = d;
  1342.   foo2[1] = e;
  1343.   foo = foo1 + foo2;
  1344.  
  1345.   VSpace dt = d.GetSpace(TANGENT);
  1346.   VSpace bt = b.GetSpace(TANGENT);
  1347.  
  1348.   truth((a.CPSpaceSize() == 1), TRUE);
  1349.   truth((a[0] == a), TRUE);
  1350.  
  1351.   ASpace cptest("cptest", foo, FALSE);
  1352.   VSpace cpt = cptest.GetSpace(TANGENT);
  1353.  
  1354.   SpaceList foo3 = SpaceList(cptest) + foo2;
  1355.   ASpace cptest2("cptest2", foo3, FALSE);
  1356.  
  1357.   truth((cptest.Dim() == 9), TRUE);
  1358.   truth((cptest.CPSpaceSize() == 5), TRUE);
  1359.   truth((cptest[0] == a), TRUE);
  1360.   truth((cptest[1] == b), TRUE);
  1361.   truth((cptest[2] == c), TRUE);
  1362.   truth((cptest[3] == d), TRUE);
  1363.   truth((cptest[4] == e), TRUE);
  1364.  
  1365.   truth((cpt[3] == dt), TRUE);
  1366.   truth((cpt[1] == bt), TRUE);
  1367.  
  1368.   truth((cptest2.Dim() == 13), TRUE);
  1369.   truth((cptest2[0] == a), TRUE);
  1370.   truth((cptest2[1] == b), TRUE);
  1371.   truth((cptest2[2] == c), TRUE);
  1372.   truth((cptest2[3] == d), TRUE);
  1373.   truth((cptest2[4] == e), TRUE);
  1374.   truth((cptest2[5] == d), TRUE);
  1375.   truth((cptest2[6] == e), TRUE);
  1376.  
  1377. //
  1378. // The following will not work with g++ 1.37.1 due to problems
  1379. // with premature destructor calls (which shows up when matrices
  1380. // of size > 4 use the heap):
  1381. //
  1382.  
  1383.   Simplex stdcp = cptest.StdSimplex();
  1384.   APoint ss3 = stdcp[3];
  1385.   cout << ss3;
  1386.  
  1387.   VSpace av("av", 1, TRUE);
  1388.   VSpace bv("bv", 2, FALSE);
  1389.   VSpace cv("cv", 2, TRUE);
  1390.  
  1391.   VSpace cvd = cv.Dual();
  1392.  
  1393.   SpaceList foov(av, bv, cv);
  1394.   VSpace cpv("cpv", foov, FALSE);
  1395.   VSpace cpvd = cpv.Dual();
  1396.  
  1397.   truth((cpv.Dim() == 5), TRUE);
  1398.   truth((cpv.CPSpaceSize() == 3), TRUE);
  1399.   truth((cpv[0] == av), TRUE);
  1400.   truth((cpv[1] == bv), TRUE);
  1401.   truth((cpv[2] == cv), TRUE);
  1402.  
  1403.   truth((cpvd[2] == cvd), TRUE);
  1404.  
  1405. //
  1406. // Expect the same g++ problem as above:
  1407. //
  1408.  
  1409.   VBasis stbcp = cpv.StdBasis();
  1410.   Vector sb2 = stbcp[2];
  1411.   cout << sb2;
  1412. }
  1413.